﻿Public Class FormKineticMeasurement2
    Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    Private objLxjcInfo As New clsLxjcInfo
    Private objProdInfo As New clsProdInfo
    Private objProdSpec As New clsProdSpec
    Private objLhPgd As New clsLhPgd
    Private en1 As entity_lxjcInfo2
    Public usr As String
    Private Sub FormKineticMeasurement2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txt_scbh.Select()
    End Sub

    Private Sub search()
        '查询力学检测信息
        Dim dtLxjcTable As DataTable = objLxjcInfo.SelectByProdId(txt_scbh.Text.Trim())
        If dtLxjcTable.Rows.Count = 0 Then
            MsgBox("该标签号未入库，请先入库", vbYes, "提示")
        End If
        If dtLxjcTable.Rows.Count = 1 Then
            If DBNull.Value.Equals(dtLxjcTable.Rows(0)("status")) Then
                Label1.Text = dtLxjcTable.Rows(0)("b_pgd_mes_sys_id")
                '查询硫化信息
                Dim dttable As DataTable = objProdInfo.getProdInfoById(txt_scbh.Text.Trim(), "12")
                If dttable.Rows.Count > 0 Then
                    txt_initial_spec1.Text = dttable.Rows(0)("prod_spec_id")
                    txt_plate_number.Text = dttable.Rows(0)("lhj_id")
                    txt_steel_seal_no.Text = dttable.Rows(0)("steel_seal_no")
                    txt_jl_type.Text = dttable.Rows(0)("jp_type")
                    txt_mould_number.Text = dttable.Rows(0)("mould_no")
                    If String.IsNullOrEmpty(txt_initial_spec1.Text.Trim()) = False Then
                        Dim dtt As DataTable = objProdSpec.getProdSpecInfo(txt_initial_spec1.Text.Trim())
                        If dtt.Rows.Count > 0 Then
                            txt_model1.Text = dtt.Rows(0)("prod_spec_name")
                            txt_xj_height_total.Value = dtt.Rows(0)("xj_height_total")
                            If dtt.Rows(0)("vertical_stiffness_standard").Equals(DBNull.Value) Then
                                txt_vertical_stiffness_standard.Value = 0
                            Else
                                txt_vertical_stiffness_standard.Value = Decimal.Parse(dtt.Rows(0)("vertical_stiffness_standard"))
                            End If
                            If dtt.Rows(0)("yield_force_standard").Equals(DBNull.Value) Or dtt.Rows(0)("yield_force_standard").Equals(String.Empty) Then
                                txt_yield_force_standard.Value = 0
                            Else
                                txt_yield_force_standard.Value = Decimal.Parse(dtt.Rows(0)("yield_force_standard"))
                            End If
                            If dtt.Rows(0)("post_yield_stiffness_standard").Equals(DBNull.Value) Or dtt.Rows(0)("post_yield_stiffness_standard").Equals(String.Empty) Then
                                txt_post_yield_stiffness_standard.Value = 0
                            Else
                                txt_post_yield_stiffness_standard.Value = Decimal.Parse(dtt.Rows(0)("post_yield_stiffness_standard"))
                            End If
                            If dtt.Rows(0)("equivalent_stiffness_standard").Equals(DBNull.Value) Or dtt.Rows(0)("equivalent_stiffness_standard").Equals(String.Empty) Then
                                txt_equivalent_stiffness_standard.Value = 0
                            Else
                                txt_equivalent_stiffness_standard.Value = Decimal.Parse(dtt.Rows(0)("equivalent_stiffness_standard"))
                            End If
                            If dtt.Rows(0)("equivalent_damping_ratio_standard").Equals(DBNull.Value) Or dtt.Rows(0)("equivalent_damping_ratio_standard").Equals(String.Empty) Then
                                txt_equivalent_damping_ratio_standard.Value = 0
                            Else
                                txt_equivalent_damping_ratio_standard.Value = Decimal.Parse(dtt.Rows(0)("equivalent_damping_ratio_standard"))
                            End If
                            txt_design_area.Text = dtt.Rows(0)("design_area")
                        End If
                    End If
                    If String.IsNullOrEmpty(dttable.Rows(0)("b_pgd_lh_details_sys_id")) = False Then
                        Dim dtlh As DataTable = objLhPgd.getListBySysId(dttable.Rows(0)("b_pgd_lh_details_sys_id"))
                        txt_Name.Text = dtlh.Rows(0)("mes_project_name")
                    End If
                Else
                    MsgBox("该生产编号不在力学仓库无法进行力学检测！", vbYes, "提示")
                End If
            Else

            End If
        Else

        End If
    End Sub

    Private Sub txt_scbh_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txt_scbh.KeyPress
        If String.IsNullOrEmpty(txt_scbh.Text.Trim()) = False Then
            If e.KeyChar = vbCr Then
                search()
            End If
        End If
    End Sub

    Private Sub clearForm1()
        'For Each obj As Object In Me.Controls
        '    If obj.GetType.ToString = "DevExpress.XtraEditors.TextEdit" Or
        '       obj.GetType.ToString = "System.Windows.Forms.ComboBox" Or
        '       obj.GetType.ToString = "DevExpress.XtraEditors.MemoEdit" Then
        '        obj.text = String.Empty
        '    End If
        '    If obj.GetType.ToString = "DevExpress.XtraEditors.SpinEdit" Then
        '        obj.Text = "0"
        '    End If
        'Next
        txt_vertical_stiffness.Value = 0
        txt_yield_force.Value = 0
        txt_post_yield_stiffness.Value = 0
        txt_equivalent_stiffness.Value = 0
        txt_equivalent_damping_ratio.Value = 0
        txt_shear_modulus.Value = 0
        txt_warehousing_area.Text = String.Empty
        txt_judgment_mechanical_properties.Text = String.Empty
    End Sub

    Private Sub setEntity1(sysId As String)
        en1 = New entity_lxjcInfo2
        With en1
            .sys_id = sysId
            .factory_id = g_factory_id
            .prod_id = txt_scbh.Text.Trim()
            .project_name = txt_Name.Text.Trim()
            .initial_spec = txt_initial_spec1.Text.Trim()
            .model = txt_model1.Text.Trim()
            .jl_type = txt_jl_type.Text

            .vertical_stiffness = txt_vertical_stiffness.Value
            .yield_force = txt_yield_force.Value
            .post_yield_stiffness = txt_post_yield_stiffness.Value
            .equivalent_stiffness = txt_equivalent_stiffness.Value
            .equivalent_damping_ratio = txt_equivalent_damping_ratio.Value
            .shear_modulus = txt_shear_modulus.Value

            .vertical_stiffness_standard = txt_vertical_stiffness_standard.Value
            .yield_force_standard = txt_yield_force_standard.Value
            .post_yield_stiffness_standard = txt_post_yield_stiffness_standard.Value
            .equivalent_stiffness_standard = txt_equivalent_stiffness_standard.Value
            .equivalent_damping_ratio_standard = txt_equivalent_damping_ratio_standard.Value
            .design_area = txt_design_area.Text.Trim()
            '力学性能差异值
            .vertical_stiffness_result = txt_vertical_stiffness_result.Value
            .yield_force_result = txt_yield_force_result.Value
            .post_yield_stiffness_result = txt_post_yield_stiffness_result.Value
            .equivalent_stiffness_result = txt_equivalent_stiffness_result.Value
            .equivalent_damping_ratio_result = txt_equivalent_damping_ratio_result.Value

            .total_thickness_rubber_layer = txt_xj_height_total.Value

            .judgment_mechanical_properties = txt_judgment_mechanical_properties.Text.Trim()

            '其他
            .warehousing_area = txt_warehousing_area.Text.Trim()
            .mould_number = txt_mould_number.Text.Trim()
            .plate_number = txt_plate_number.Text.Trim()

            .ope = usr
            .b_pgd_mes_sys_id = Label1.Text
            .update_time = Now()
        End With

    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If chkEmpty(txt_scbh) = False Then Exit Sub
        If chkEmpty(txt_Name) = False Then Exit Sub
        If chkEmpty(txt_initial_spec1) = False Then Exit Sub
        If chkEmpty(txt_model1) = False Then Exit Sub
        If chkEmpty(txt_jl_type) = False Then Exit Sub

        If chkZero(txt_vertical_stiffness) = False Or chkNegative(txt_vertical_stiffness) = False Then
            Exit Sub
        End If
        'If chkZero(txt_yield_force) = False Or chkNegative(txt_yield_force) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_post_yield_stiffness) = False Or chkNegative(txt_post_yield_stiffness) = False Then
        '    Exit Sub
        'End If
        If chkZero(txt_equivalent_stiffness) = False Or chkNegative(txt_equivalent_stiffness) = False Then
            Exit Sub
        End If
        'If chkZero(txt_equivalent_damping_ratio) = False Or chkNegative(txt_equivalent_damping_ratio) = False Then
        '    Exit Sub
        'End If
        If chkZero(txt_shear_modulus) = False Or chkNegative(txt_shear_modulus) = False Then
            Exit Sub
        End If
        'If chkZero(txt_vertical_stiffness_standard) = False Or chkNegative(txt_vertical_stiffness_standard) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_yield_force_standard) = False Or chkNegative(txt_yield_force_standard) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_post_yield_stiffness_standard) = False Or chkNegative(txt_post_yield_stiffness_standard) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_equivalent_stiffness_standard) = False Or chkNegative(txt_equivalent_stiffness_standard) = False Then
        '    Exit Sub
        'End If

        'If chkZero(txt_equivalent_damping_ratio_standard) = False Or chkNegative(txt_equivalent_damping_ratio_standard) = False Then
        '    Exit Sub
        'End If
        'If chkEmpty(txt_design_area) = False Then Exit Sub
        'If chkZero(txt_vertical_stiffness_result) = False Or chkNegative(txt_vertical_stiffness_result) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_yield_force_result) = False Or chkNegative(txt_yield_force_result) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_post_yield_stiffness_result) = False Or chkNegative(txt_post_yield_stiffness_result) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_equivalent_stiffness_result) = False Or chkNegative(txt_equivalent_stiffness_result) = False Then
        '    Exit Sub
        'End If
        'If chkZero(txt_equivalent_damping_ratio_result) = False Or chkNegative(txt_equivalent_damping_ratio_result) = False Then
        '    Exit Sub
        'End If
        If chkZero(txt_xj_height_total) = False Or chkNegative(txt_xj_height_total) = False Then
            Exit Sub
        End If

        If chkEmpty(txt_judgment_mechanical_properties) = False Then Exit Sub

        'If chkZero(txt_lead_core_height) = False Or chkNegative(txt_lead_core_height) = False Then
        '    Exit Sub
        'End If

        'If chkZero(txt_lead_core_weight) = False Or chkNegative(txt_lead_core_weight) = False Then
        '    Exit Sub
        'End If
        'If chkEmpty(txt_lead_core_factory) = False Then Exit Sub
        'If chkEmpty(txt_lead_free_conversion) = False Then Exit Sub

        'If chkEmpty(txt_judgment_basis) = False Then Exit Sub

        If chkEmpty(txt_warehousing_area) = False Then Exit Sub

        If chkEmpty(txt_mould_number) = False Then Exit Sub

        If chkEmpty(txt_plate_number) = False Then Exit Sub

        Dim dtx As DataTable = objProdInfo.getProdInfoById(txt_scbh.Text.Trim(), "12")

        If dtx.Rows.Count = 0 Then
            MsgBox("该生产编号不在力学仓库无法进行力学检测！", vbYes, "提示")
            Exit Sub
        End If

        Dim dtLxjcTable As DataTable = objLxjcInfo.SelectByProdId(txt_scbh.Text.Trim())
        setEntity1(dtLxjcTable.Rows(0)("sys_id"))
        If DBNull.Value.Equals(dtLxjcTable.Rows(0)("status")) Then
            If objLxjcInfo.update2(en1) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                clearForm1()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
    End Sub

    Private Sub txt_vertical_stiffness_TextChanged(sender As Object, e As EventArgs) Handles txt_vertical_stiffness.TextChanged
        If txt_vertical_stiffness_standard.Value <> 0 Then
            Dim rtn = ((txt_vertical_stiffness.Value - txt_vertical_stiffness_standard.Value) / txt_vertical_stiffness_standard.Value)
            txt_vertical_stiffness_result.Value = FormatNumber(rtn, 2, vbTrue)
        End If
    End Sub

    Private Sub txt_post_yield_stiffness_TextChanged(sender As Object, e As EventArgs) Handles txt_post_yield_stiffness.TextChanged
        If txt_post_yield_stiffness_standard.Value <> 0 Then
            Dim rtn = ((txt_post_yield_stiffness.Value - txt_post_yield_stiffness_standard.Value) / txt_post_yield_stiffness_standard.Value)
            txt_post_yield_stiffness_result.Value = FormatNumber(rtn, 2, vbTrue)
        End If
    End Sub

    Private Sub txt_equivalent_damping_ratio_TextChanged(sender As Object, e As EventArgs) Handles txt_equivalent_damping_ratio.TextChanged
        If txt_equivalent_damping_ratio_standard.Value <> 0 Then
            Dim rtn = ((txt_equivalent_damping_ratio.Value - txt_equivalent_damping_ratio_standard.Value) / txt_equivalent_damping_ratio_standard.Value)
            txt_equivalent_damping_ratio_result.Value = FormatNumber(rtn, 2, vbTrue)
        End If
    End Sub

    Private Sub txt_yield_force_TextChanged(sender As Object, e As EventArgs) Handles txt_yield_force.TextChanged
        If txt_yield_force_standard.Value <> 0 Then
            Dim rtn = ((txt_yield_force.Value - txt_yield_force_standard.Value) / txt_yield_force_standard.Value)
            txt_yield_force_result.Value = FormatNumber(rtn, 2, vbTrue)
        End If
    End Sub

    Private Sub txt_equivalent_stiffness_TextChanged(sender As Object, e As EventArgs) Handles txt_equivalent_stiffness.TextChanged
        If txt_equivalent_stiffness_standard.Value <> 0 Then
            Dim rtn = ((txt_equivalent_stiffness.Value - txt_equivalent_stiffness_standard.Value) / txt_equivalent_stiffness_standard.Value)
            txt_equivalent_stiffness_result.Value = FormatNumber(rtn, 2, vbTrue)
        End If
    End Sub


    Private Sub txt_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_vertical_stiffness.MouseDown, txt_xj_height_total.MouseDown,
        txt_shear_modulus.MouseDown, txt_post_yield_stiffness.MouseDown,
        txt_equivalent_stiffness.MouseDown, txt_equivalent_damping_ratio.MouseDown, txt_yield_force.MouseDown
        UcDigitalKeyboard1 = New ucDigitalKeyboard
        If sender.MaskBox.Mask.EditMask = "d" Then
            UcDigitalKeyboard1.B_01 = False
        Else
            UcDigitalKeyboard1.B_01 = True
        End If

        If sender.GetType().Name.Equals("TextEdit") Then
            UcDigitalKeyboard1.B_02 = True
        Else
            UcDigitalKeyboard1.B_02 = False
        End If

        UcDigitalKeyboard1.Txt = sender

        Me.Controls.Add(UcDigitalKeyboard1)
        UcDigitalKeyboard1.Show()
        UcDigitalKeyboard1.BringToFront()
        UcDigitalKeyboard1.Focus()

    End Sub

    Private Sub ucdigitalkeyboard1_leave(sender As Object, e As EventArgs) Handles UcDigitalKeyboard1.Leave
        UcDigitalKeyboard1.Dispose()
    End Sub

End Class

Public Class entity_lxjcInfo2
    Public sys_id As String
    Public factory_id As String
    '支座信息
    Public prod_id As String
    Public project_name As String
    Public initial_spec As String
    Public model As String
    Public jl_type As String
    '力学性能检测值
    Public vertical_stiffness As String '竖向刚度
    Public yield_force As String '屈服力
    Public post_yield_stiffness As String '屈服后刚度
    Public equivalent_stiffness As String '等效刚度
    Public equivalent_damping_ratio As String '等效阻尼比
    Public shear_modulus As String '剪切模量
    '力学性能设计值
    Public vertical_stiffness_standard As String '竖向刚度
    Public yield_force_standard As String '屈服力
    Public post_yield_stiffness_standard As String '屈服后刚度
    Public equivalent_stiffness_standard As String '等效刚度
    Public equivalent_damping_ratio_standard As String '等效阻尼比
    Public design_area As String '设计区域
    '力学性能差异值
    Public vertical_stiffness_result As String '竖向刚度
    Public yield_force_result As String '屈服力
    Public post_yield_stiffness_result As String '屈服后刚度
    Public equivalent_stiffness_result As String '等效刚度
    Public equivalent_damping_ratio_result As String '等效阻尼比

    Public total_thickness_rubber_layer As String '橡胶层总厚度

    Public judgment_mechanical_properties As String '力学性能判断

    '其他
    Public warehousing_area As String '入库区域
    Public mould_number As String '模具编号
    Public plate_number As String '平板编号

    Public ope As String
    Public b_pgd_mes_sys_id As String
    Public update_time As String
End Class
